<?php
/*
 * 会员处理
 * @arrange Mark
 * @package ixdcw
 * @file    members.inc.php
 * @time    12-12-19 下午1:05
 */
defined('IN_IXDCW') or exit('Access Denied');
require DT_CORE.'/'.$module.'/common.inc.php';
if(!check_group($_groupid, $MOD['group_search'])) {
	$head_title = lang('message->without_permission');
	include template('noright', 'message');
	exit;
}

if($gid) {
	if(!$areaid && $cityid && strpos($DT_URL, 'areaid') === false) {
		$areaid = $cityid;
		$ARE = $AREA[$cityid];
	}
	$fds = $MOD['fields'];
	$condition = "groupid>5 AND catids<>''";
	$condition = "groupid={$gid}";
	if($areaid) $condition .= ($ARE['child']) ? " AND areaid IN (".$ARE['arrchildid'].")" : " AND areaid=$areaid";

	$pagesize = $MOD['pagesize'];
	$offset = ($page-1)*$pagesize;
	//echo $condition;
	$items = $db->count($table, $condition, $DT['cache_search']);
	$pages = pages($items, $page, $pagesize);
	if($items) {
		$order = $MOD['order'] ? " ORDER BY ".$MOD['order'] : '';
		$sql = "SELECT $fds FROM {$table} WHERE {$condition}{$order} LIMIT {$offset},{$pagesize}";
		//echo $sql;
		$result = $db->query($sql, $DT['cache_search'] && $page == 1 ? 'CACHE' : '', $DT['cache_search']);

		while($r = $db->fetchArray($result)) {
			if($kw) $r['company'] = str_replace($replacef, $replacet, $r['company']);
			$tags[] = $r;
		}
		$db->freeResult($result);
		if($page == 1 && $kw) keyword($kw, $items, $moduleid);
	}
}
$showpage = 1;
$seo_file = 'search';
include DT_INC.'/seo.inc.php';
include template('members', $module);
?>